package com.yuexun.dhdoctor.module.meetingMaterial.presenter.impl;

import com.yuexun.dhdoctor.module.meetingMaterial.bean.MeetingMaterialFeedBack;
import com.yuexun.dhdoctor.module.meetingMaterial.model.IMeetingMaterialFeedBackModel;
import com.yuexun.dhdoctor.module.meetingMaterial.presenter.IMeetingMaterialFeedBackPresenter;
import com.yuexun.dhdoctor.module.meetingMaterial.ui.IMeetingMaterialFeedBackView;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/12/22.
 */
public class MeetingMaterialFeedBackPresenter implements IMeetingMaterialFeedBackPresenter {
    IMeetingMaterialFeedBackView mView;
    IMeetingMaterialFeedBackModel mModel;

    public MeetingMaterialFeedBackPresenter(IMeetingMaterialFeedBackView view, IMeetingMaterialFeedBackModel model){
        this.mView=view;
        this.mModel=model;
    }

    @Override
    public void meetFeedBack(Map<String, String> praise) {
        mModel.meetingFeedBack(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<MeetingMaterialFeedBack>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(MeetingMaterialFeedBack meetingMaterialFeedBack) {
                        mView.meetFeedback(meetingMaterialFeedBack);
                    }
                });
    }
}
